package core;

import gitobject.JitIndex;
import repository.Repository;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;

import fileoperation.FileReader;

public class JitRm {
    /**
     * Delete files in your index.
     * @param filename
     * @throws IOException 
     */
    @SuppressWarnings("unused")
	public static void rm(String filename) throws IOException {
        /* Todo: You should pass the filename in this function, and generate a hash file in your repository.
        *   Add your code here.*/

    	if(JitMap.safeRemoveIndex(filename)) {
            System.out.printf("rm '%s'\n", filename);
            try {
                JitMap.index.compressWrite();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        else System.out.printf("fatal: pathspec '%s' did not match any files", filename);
    }
}